package com.shire.shire_interface.constants;

import com.shire.shire_interface.common.utils.StrUtils;

import java.util.EnumSet;

public class WxConstants {
    public enum CmdPriority{
        UNKNOWN(0, "普通消息"), MASSMSG(10,"群发消息"), INVITE(20, "群发"), JOINGROUP(30, "加群"), TIMLIMELINE(40, "朋友圈");
        private int code;
        private String title;

        CmdPriority(Integer code, String title){
            this.code = code;
            this.title = title;
        }
        public int getCode(){
            return code;
        }
        public String getTitle(){
            return title;
        }

        public static CmdPriority get(Integer code){
            if(code==null){
                return UNKNOWN;
            }
            for (CmdPriority e : EnumSet.allOf(CmdPriority.class)) {
                if(e.getCode()==code) return e;
            }
            return UNKNOWN;
        }
    }

    public enum CmdTaskType{
        UNKNOWN(-1, "未知"), INVITE(1,"邀请好友"), MASSMSG(2, "群发"), JOINGROUP(3, "加群"), TIMLIMELINE(4, "朋友圈"), VALIDATION(5, "通过验证");

        private int code;
        private String title;

        CmdTaskType(Integer code, String title){
            this.code = code;
            this.title = title;
        }
        public int getCode(){
            return code;
        }
        public String getTitle(){
            return title;
        }

        public static CmdTaskType get(Integer code){
            if(code==null){
                return UNKNOWN;
            }
            for (CmdTaskType e : EnumSet.allOf(CmdTaskType.class)) {
                if(e.getCode()==code) return e;
            }
            return UNKNOWN;
        }
    }


    public enum FriendAddType{
        UNKNOWN(-1, "未知"), FROMGROUP(0,"通过群好友添加对方"), FROMSEARCH(1, "搜过添加对方"), ADDED(2, "被对方添加"), ;

        private int code;
        private String title;

        FriendAddType(Integer code, String title){
            this.code = code;
            this.title = title;
        }
        public int getCode(){
            return code;
        }
        public String getTitle(){
            return title;
        }

        public static FriendAddType get(Integer code){
            if(code==null){
                return UNKNOWN;
            }
            for (FriendAddType e : EnumSet.allOf(FriendAddType.class)) {
                if(e.getCode()==code) return e;
            }
            return UNKNOWN;
        }
    }

    /**
     * 指令状态
     */
    public enum CmdStatus{
        UNKNOWN(-1, "未知"),NEW(0, "新建"),WAIT(1, "待发送"),SENT(2, "已发送"),PROCESSING(3, "执行中"),
        SUCCESSED(4, "成功"),FAILED(5, "失败"),PAUSE(6, "暂停"), ABANDON(7, "废弃"), TIMEOUT(8, "超时"),
        MAN_FINISHED(9, "指定完成"), TRY_TIMES_OVER(10, "重试超出次数"),
        EXCEPTION(99, "异常");
        private String title;
        private int code;
        CmdStatus(int code, String title){
            this.title = title;
            this.code = code;
        }
        public int getCode(){
            return code;
        }
        public String getTitle(){
            return title;
        }

        public static CmdStatus get(Integer code){
            if(code==null){
                return UNKNOWN;
            }
            for (CmdStatus e : EnumSet.allOf(CmdStatus.class)) {
                if(e.getCode()==code) return e;
            }
            return UNKNOWN;
        }
    }

    public enum CmdType{
        UNKNOWN("unknown", "未知", 0),
        CRK_LOGIN_AGAIN("crk_login_again", "重新登录", 10),
        CRK_REQ_CURRENT("crk_req_current", "请求当前设备状态", 11),
        CRK_ADD_FRIEND("crk_add_friend", "请求添加好友", 20),
        CRK_JOIN_GROUP("crk_join_group", "请求添加群", 21),
        CRK_INVITE_GROUP("crk_invite_group", "邀请好友进群", 22),
        //        CRK_ADD_GROUP_ADDRESS("crk_add_group_address", "(废弃)添加群进通讯录", 23),
        CRK_QUIT_GROUP("crk_quit_group", "退群", 24),
        CRK_SYNC_ADDRESS("crk_sync_address", "同步通讯录", 25),
        CRK_SYNC_GROUP("crk_sync_group", "同步群", 26),
        CRK_SCAN_IMAGE("crk_scan_image", "识别图片", 27),
        CRK_SEND_CHAT("crk_send_chat", "发送聊天", 30),
        CRK_SEND_LINK("crk_send_ad", "发送广告", 31),
        CRK_SEND_MP("crk_send_ad", "发送小程序", 32),

        CRK_SEND_CARD("crk_send_card", "发送个人名片", 33),
        CRK_ACCEPT_CARD("crk_accept_card", "点击名片添加好友", 34),
        CRK_ADD_WXID("crk_add_wxid", "根据微信号添加好友", 35),
        CRK_UPDATE_PROFILE("crk_update_profile", "更新个人信息", 36),
        CRK_FETCH_SELF("crk_fecth_self", "获取个人信息", 37),
        CRK_PASS_FRIEND("crk_pass_all_verifications", "自动通过好友验证", 41),
        CRK_CLEAR_GROUP("crk_clear_group", "自动清除群聊天", 42),
        CRK_INVITE_GROUP_D("crk_invite_group_d", "直接拉好友进群", 43),
        CRK_CREATE_CROUP("crk_create_group","创建群聊",44),
        CRK_REMOVE_GROUP_USERS_D("crk_remove_group_users_d","移除群成员",45),
        CRK_FETCH_TIMELINE_D("crk_fetch_timeline_d","直接获取朋友圈列表",46),
        CRK_LIKE_TIMELINE_D("crk_like_timeline_d","直接点赞某条朋友圈",47),
        CRK_UNLIKE_TIMELINE_D("crk_unlike_timeline_d","直接取消点赞某条朋友圈",48),
        CRK_COMMENT_TIMELINE_D("crk_comment_timeline_d","直接评论某条朋友圈",49),
        CRK_UNCOMMENT_TIMELINE_D("crk_comment_timeline_d","直接评论某条朋友圈",50),
        CRK_HELLO_CLEAR_D("crk_hello_clear_d","直接删除所有hello",51),
        CRK_HELLO_FETCH_D("crk_hello_fetch_d","直接获取所有hello",52),
        CRK_HELLO_VERIFY_D("crk_hello_verify_ok_d","直接通过某个hello验证",53),
        CRK_HELLO_VERIFY_REPLY_D("crk_hello_verify_reply_d","直接回复某个hello验证",54),
        CRK_FETCH_USERTIMELINE_D("crk_fetch_usertimeline_d","直接获取某个用户朋友圈的列表",55),
        CRK_CREATE_GROUP_D("crk_create_group_d","直接创建群",56),
        CRK_SEND_CHAT_BATCH_D("crk_send_chat_batch_d","批量发送聊天信息",57),
        CRK_UPDATE_PROFILE_D("crk_update_profile_d","直接修改个人信息",58),

        CRK_UPDATE_GROUP_DESC_D("crk_update_group_desc_d","直接修改群公告",59),
        CRK_UPDATE_GROUP_SELF_DISPLAY_NAME_D("crk_update_group_self_display_name_d","直接修改个人群昵称",60),
        CRK_REVOKE_MESSAGE_D("crk_revoke_message_d","直接撤回消息",61),
        CRK_SET_GROUP_NAME_D("crk_set_group_name_d","直接修改群名称",62),

        CRK_FORWARD_MESSAGE_D("crk_forward_message_d", "直接转发", 70),

        CRK_SEND_CHAT_D("crk_send_chat_d", "直发聊天", 80),
        CRK_SEND_CHAT_D_IMAGE("crk_send_chat_d_image", "直发图片", 81),
        CRK_SEND_CHAT_D_NAMECARD("crk_send_chat_d_namecard", "直发名片", 82),
        CRK_SEND_CHAT_D_LINK("crk_send_chat_d_link", "直发链接", 83),
        CRK_SEND_CHAT_D_FILE("crk_send_chat_d_file", "直发文件", 84),
        CRK_SEND_CHAT_D_VIDEO("crk_send_chat_d_video", "直发视频", 85),

        CRK_SEND_TIMELINE_LINK_D("crk_send_timeline_link_d", "直发朋友圈链接", 86),
        CRK_SEND_TIMELINE_IMAGE_D("crk_send_timeline_images_d", "直发朋友圈文件", 87),
        CRK_SEND_TIMELINE_VIDEO_D("crk_send_timeline_video_d", "直发朋友圈视频", 88),
        CRK_SEND_TIMELINE_TEXT_D("crk_send_timeline_text_d", "直发朋友圈视频", 89),

        CRK_CLEAR_DEVICE_INFO("crk_clear_deviceinfo", "清除设备信息", 90),
        CRK_QUIT_GROUP_D("crk_quit_group_d", "退群", 91),

        CRK_SCREEN_SHOT("crk_screen_shot", "当前截屏", 200),
        CRK_SCREEN_TAP("crk_screen_tap", "点击屏幕", 201),
        ;
        private String op;
        private String title;
        private int type;
        private String priority;
        private String url;
        CmdType(String op, String title, int type){
            this.op = op;
            this.title = title;
            this.type = type;
//            url = URL_COMMON_CRK;
//            url += "?cmd=" + op;
        }

        public String getOp(){
            return op;
        }
        public String getTitle(){
            return title;
        }

        public String getUrl(){
            return url;
        }

        public int getType(){
            return type;
        }

        public int getCode(){
            return type;
        }

        public String getPriority() {
            return priority;
        }

        public static CmdType get(Integer code){
            if(code==null){
                return UNKNOWN;
            }
            for (CmdType e : EnumSet.allOf(CmdType.class)) {
                if(e.getCode()==code) return e;
            }
            return UNKNOWN;
        }

        public static CmdType get(String op){
            if(StrUtils.isBlank(op)){
                return null;
            }
            for (CmdType e : EnumSet.allOf(CmdType.class)) {
                if(e.getOp().equals(op)) return e;
            }
            return null;
        }
    }

    public enum MessageType {
        UNKNOWN(0, "未知", "unknown"),TEXT(1, "文本", "text"), PIC(2, "图片", "pic"), EMOTION(3, "表情", "emotion"),
        VIDEO(4, "视频", "video"), VOICE(5, "语音", "voice"), FILE(6, "文件", "file"),  NOTE_RED_PACKETS(7, "红包", "red"),
        NOTE_ADD_FRIEND_SUCCESS(8, "添加好友成功", "add_friend_success"), NOTE_JOIN_GROUP(9, "加入群聊", "join_group"),
        LINK_CARD(10, "链接卡片", "link"),MINI_PROGRAM(11, "小程序", "mp"),
        UNKONOW_SHARING(12, "未知分享", "un_share"),
        FRIEND_CARD(13, "好友名片", "friend_card"),
        SHARING_GROUP_CARD(14, "群邀请", "share_group"),
        GROUP_NOTICE(15, "群公告", "group_notice"),
        FORWARD_MSG(16,"转发消息","forward_msg")
        ;
        private String title;
        private int code;
        private String type;
        private MessageType(int code, String title, String type){
            this.code = code;
            this.title = title;
            this.type = type;
        }

        public String getTitle(){
            return title;
        }

        public int getCode(){
            return code;
        }

        public String getType(){
            return type;
        }

        public static MessageType get(Integer code){
            if(code==null) return UNKNOWN;
            for (MessageType e : EnumSet.allOf(MessageType.class)) {
                if(e.code==code) return e;
            }
            return UNKNOWN;
        }
    }

    public enum ChatFrom {
        SYSTEM("系统"),SELF("自己"),FRIEND("好友"), GROUP("群");
        private String title;
        private ChatFrom(String title){
            this.title = title;
        }

        public String getTitle(){
            return title;
        }

        public int getCode(){
            return ordinal();
        }

        public static ChatFrom get(int code){
            for (ChatFrom e : EnumSet.allOf(ChatFrom.class)) {
                if(e.ordinal()==code) return e;
            }
            return SYSTEM;
        }
    }
    public enum ValidationStatus {
        UNKNOWN("未知", 0), PASSED("已添加",1), WAIT("待验证",2), REPLIED("验证回复", 3), OVERTIME("已过期", 4);
        private String title;
        private Integer code;
        private ValidationStatus(String title, Integer code){
            this.title = title;
            this.code = code;
        }

        public String getTitle(){
            return title;
        }

        public int getCode(){
            return ordinal();
        }

        public static ValidationStatus get(int code){
            for (ValidationStatus e : EnumSet.allOf(ValidationStatus.class)) {
                if(e.ordinal()==code) return e;
            }
            return WAIT;
        }
    }

    public enum TaskStatus {
        NEW("新建"),GENERATING("生成中"), RUNNING("待执行"), PAUSE("暂停"), FINISHED("完成"), ABANDON("废弃");
        private String title;
        TaskStatus(String title){
            this.title = title;
        }

        public String getTitle(){
            return title;
        }

        public int getCode(){
            return ordinal();
        }

        public static TaskStatus get(Integer code){
            if(code==null) return NEW;
            for (TaskStatus e : EnumSet.allOf(TaskStatus.class)) {
                if(e.ordinal()==code) return e;
            }
            return NEW;
        }
    }

    public enum AccountStatus {
        ENABLE("正常"), LOGOUT("登出"), BAN("封号"), VERIFY("验证"), DELETE("逻辑删除"), LOST("被盗"), GAMBLE("赌博"), EXCEPTION("异常");
        private String title;

        private AccountStatus(String title){
            this.title = title;
        }

        public String getTitle(){
            return title;
        }

        public int getCode(){
            return ordinal();
        }

        public static AccountStatus get(int ordi){
            for (AccountStatus e : EnumSet.allOf(AccountStatus.class)) {
                if(e.ordinal()==ordi) return e;
            }
            return ENABLE;
        }
    }

    public enum RetryCode {
//        S10005(10005, 120, "微信启动失败"),
//        S10002(10002, 120, "指令执行失败"),
        S10010(10010, 120, "微信闪退"),
//        S10009(10009, 120, "指令超时，强制退出"),
//        S10011(10011, 120, "CRK升级"),
        S15001(15001, 14400, "添加群，无法打开该页"),
        ;
        private Integer status;
        private Integer delaySeconds;
        private String title;

        private RetryCode(Integer status, Integer delaySeconds, String title){
            this.status = status;
            this.delaySeconds = delaySeconds;
            this.title = title;
        }

        public String getTitle(){
            return title;
        }

        public Integer getStatus() {
            return status;
        }


        public Integer getDelaySeconds() {
            return delaySeconds;
        }

        public int getCode(){
            return status;
        }

        public static RetryCode get(int code){
            for (RetryCode e : EnumSet.allOf(RetryCode.class)) {
                if(e.status==code) return e;
            }
            return null;
        }
    }

    public enum SensitiveType {
        UNKNOWN(0, "未知"), GROUP_WAIT(1, "群卡片"), CHAT(2, "聊天");
        private String title;
        private int code;

        private SensitiveType(Integer code, String title){
            this.code = code;
            this.title = title;
        }

        public String getTitle(){
            return title;
        }

        public int getCode(){
            return code;
        }

        public static SensitiveType get(int ordi){
            for (SensitiveType e : EnumSet.allOf(SensitiveType.class)) {
                if(e.code==ordi) return e;
            }
            return UNKNOWN;
        }
    }
}
